<template>
  <div>
    <div style="display: flex;justify-items: center;align-items: center; display: flex;
  align-items: center;
  justify-content: left;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  height: 100vh;
  flex-direction: column;
">
      <!--              条件搜索区域-->


      <!--      表格头-->
      <div
          style="display: flex;align-items: center;justify-content: center;height: 5%;margin: 6px;width: 100%">

        <div style="display: flex;align-items: center;justify-content: left;width: 50%">
                    <Span
                        style="font-size: 24px;font-family: 'PingFang SC';font-weight: bolder;margin-left: 12px">项目管理</Span>
        </div>

        <!--        新增项目按钮-->
        <el-button type="success " @click="openAddProjectDialog">新增项目</el-button>

        <div style="display: flex;align-items: center;justify-content: center;width: 50%">
          <!--              任务状态选择-->
          <el-radio-group v-model="tabPosition">
            <el-radio-button label="all" @click.native="changeTab('all')">全部</el-radio-button>
            <el-radio-button label="undo" @click.native="changeTab('undo')">未开始</el-radio-button>
            <el-radio-button label="doing" @click.native="changeTab('doing')">进行中</el-radio-button>
            <el-radio-button label="done" @click.native="changeTab('done')">已完成</el-radio-button>
          </el-radio-group>
          <!--              任务模糊查询-->
          <el-input
              placeholder="请输入项目名称或Id进行搜索"
              v-model="searchValue" style="width: 49%;margin-left: 10px;margin-right: 12px">
          </el-input>
          <el-button type="primary" icon="el-icon-search" @click="selectProjectByIdOrName">搜索</el-button>

        </div>
      </div>

      <!--      表格本体-->
      <div style="display: flex;justify-items: center;margin: 12px;height: 78vh;width: 100%">
        <el-table
            :data="projectTableData"
            style="width: 100%;margin: 12px"
            stripe="true"
            height="75vh"
        >
          <el-table-column type="expand">
            <template slot-scope="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-form-item label="项目Id">
                  <span>: {{ props.row.projectId }}</span>
                </el-form-item>
                <el-form-item label="项目名称">
                  <span>: {{ props.row.projectName }}</span>
                </el-form-item>
                <el-form-item label="项目创建人">
                  <span>: {{ props.row.createUserName }}</span>
                </el-form-item>
                <el-form-item label="项目组长">
                  <span>: {{ props.row.projectLeaderName }}</span>
                </el-form-item>
                <el-form-item label="项目状态">
                  <span>: {{ props.row.projectStatusName }}</span>
                </el-form-item>
                <el-form-item label="创建时间">
                  <span>: {{ timeFormatConversion(props.row.createTime) }}</span>
                </el-form-item>
                <el-form-item label="截至时间">
                  <span>: {{ timeFormatConversion(props.row.completionTime) }}</span>
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>


          <el-table-column
              prop="projectId"
              label="项目Id"
          >
          </el-table-column>

          <el-table-column
              prop="projectName"
              label="项目名称"
          >
          </el-table-column>
          <!--          <el-table-column
                        prop="noteType"
                        label="类型">

                      <template slot-scope="scope">
                        <el-tag
                            disable-transitions
                            effect="Plain"
                        >{{ switchNoteType(scope.row.noteType).noteTypeName }}
                        </el-tag>
                      </template>

                    </el-table-column>-->

          <el-table-column
              prop="createTime"
              label="创建时间">
            <template slot-scope="scope">
              {{ timeFormatConversion(scope.row.createTime) }}
            </template>
          </el-table-column>


          <el-table-column
              prop="completionTime"
              label="完成时间">
            <template slot-scope="scope">
              {{ timeFormatConversion(scope.row.completionTime) }}
            </template>
          </el-table-column>


          <el-table-column
              prop="projectStatusName"
              label="状态">
            <template slot-scope="scope">
              <el-tag
                  :type="switchProjectStatus(scope.row.projectStatusName).tagStyle"
                  disable-transitions
                  effect="dark"
              >{{ scope.row.projectStatusName }}
              </el-tag>
            </template>
          </el-table-column>


          <el-table-column label="操作"
                           width="300px"
          >
            <template slot-scope="scope">

              <el-button
                  size="mini"
                  @click="toMyProjectEdit(scope.row)"
                  plain
              >编辑
              </el-button>
              <el-button
                  size="mini"
                  type="danger"
                  @click="delProject(scope.row.projectId)"
                  plain
              >删除
              </el-button>

              <el-button
                  size="mini"
                  type="success"
                  @click="showAssign(scope.row.projectLeaderId,scope.row)"
                  plain
              >指派
              </el-button>

              <el-button
                  size="mini"
                  type="primary"
                  @click="showProjectUsers(scope.row.projectId)"
                  plain
              >项目组员
              </el-button>

            </template>
          </el-table-column>
        </el-table>

        <!--        &lt;!&ndash;查看项目详情的弹窗&ndash;&gt;
                <el-dialog
                    title="日志详情"
                    :visible.sync="noteDialogVisible"
                    width="80%"
                >
                  <div style="display: flex;width: auto;align-items: center;justify-content: center;flex-direction: column">
                    &lt;!&ndash;            预览md区域&ndash;&gt;
                    <v-md-editor v-model="noteInfoText" height="100%"
                                 mode="preview"
                    ></v-md-editor>
                  </div>


                  <span slot="footer" class="dialog-footer">
            <el-button @click="noteDialogVisible = false">关闭</el-button>
            <el-button type="primary" @click="noteDialogVisible = false">确 定</el-button>
          </span>
                </el-dialog>-->

        <!--        项目指派项目组长-->
        <el-dialog
            title="项目指派"
            :visible.sync="assignDialogVisible"
            width="50%"
        >

          <!--                当前项目所有员工信息展示-->
          <div
              style="display: flex;height: 340px; width:100%;flex-direction: column;align-items: center; justify-items: center; background-color: white;border-radius: 12px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);">

            <el-table
                :data="projectLeaders"
                height="290px"
            >
              <el-table-column
                  prop="uid"
                  label="员工Id"
              >
              </el-table-column>
              <el-table-column
                  prop="infoName"
                  label="姓名"
              >
              </el-table-column>
              <el-table-column
                  prop="roleName"
                  label="职位">
              </el-table-column>

              <el-table-column
                  prop="depName"
                  label="部门">
              </el-table-column>

              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button
                      size="mini"
                      type="success"
                      @click="assign(scope.row.uid)"
                  >指派
                  </el-button>

                  <!--                        <el-popover
                                              placement="top"
                                              width="160"
                                              v-model="delUserFormProjectVisible"
                                              trigger="click"
                                          >
                                            <p>你确定要移除当前组员吗？</p>
                                            <div style="text-align: right; margin: 0">
                                              <el-button size="mini" type="text" @click="delUserFormProjectVisible = false">取消</el-button>
                                              <el-button type="primary" size="mini" @click="removeFormProject(scope.row.uid)">确定</el-button>
                                            </div>
                                            <el-button slot="reference" size="mini"
                                                       type="danger"
                                                       plain>移除</el-button>
                                          </el-popover>-->


                </template>
              </el-table-column>
            </el-table>
          </div>

          <span slot="footer" class="dialog-footer">
            <el-button @click="assignDialogVisible = false">关闭</el-button>
            <el-button type="primary" @click="assignDialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>


        <!--项目组员弹窗-->
        <el-dialog
            title="项目组员信息"
            :visible.sync="projectMembersDialogVisible"
            width="50%"
        >

          <!--                当前项目所有员工信息展示-->
          <div
              style="display: flex;height: 340px; width:100%;flex-direction: column;align-items: center; justify-items: center; background-color: white;border-radius: 12px;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);">

            <el-table
                :data="projectUsersList"
                height="290px"
            >
              <el-table-column
                  prop="uid"
                  label="员工Id"
              >
              </el-table-column>
              <el-table-column
                  prop="infoName"
                  label="姓名"
              >
              </el-table-column>
              <el-table-column
                  prop="roleName"
                  label="职位">
              </el-table-column>

              <el-table-column
                  prop="depName"
                  label="部门">
              </el-table-column>

              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button
                      size="mini"
                      @click="showUserInfo(scope.row.uid)"
                  >详情
                  </el-button>

                  <el-button
                      size="mini"
                      type="danger"
                      plain
                      @click="removeFormProject(scope.row.uid)">移除
                  </el-button>
                  <!--                        <el-popover
                                              placement="top"
                                              width="160"
                                              v-model="delUserFormProjectVisible"
                                              trigger="click"
                                          >
                                            <p>你确定要移除当前组员吗？</p>
                                            <div style="text-align: right; margin: 0">
                                              <el-button size="mini" type="text" @click="delUserFormProjectVisible = false">取消</el-button>
                                              <el-button type="primary" size="mini" @click="removeFormProject(scope.row.uid)">确定</el-button>
                                            </div>
                                            <el-button slot="reference" size="mini"
                                                       type="danger"
                                                       plain>移除</el-button>
                                          </el-popover>-->


                </template>
              </el-table-column>
            </el-table>
          </div>

          <span slot="footer" class="dialog-footer">
            <el-button @click="projectMembersDialogVisible = false">关闭</el-button>
            <el-button type="primary" @click="projectMembersDialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>

        <!--                 项目组员详细信息显示弹窗 -->
        <el-dialog
            title="详情"
            :visible.sync="userInfoDialogVisible"
            width="30%"

        >
          <div style="display: flex;width: 100%;align-items: center;justify-content: center">
            <el-descriptions class="margin-top" title="员工详细信息" :column="3" size="medium" border>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-d-caret"></i>
                  用户Id
                </template>
                {{ userInfo.uid }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-user"></i>
                  用户名
                </template>
                {{ userInfo.name }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-mobile-phone"></i>
                  手机号
                </template>
                {{ userInfo.phone }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-edit"></i>
                  姓名
                </template>
                {{ userInfo.infoName }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-message"></i>
                  邮箱
                </template>
                {{ userInfo.email }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-male"></i>
                  <i class="el-icon-female"></i>
                  性别
                </template>
                {{ userInfo.gender }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-s-custom"></i>
                  职位
                </template>
                {{ userInfo.roleName }}
              </el-descriptions-item>

              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-s-data"></i>
                  部门
                </template>
                {{ userInfo.depName }}
              </el-descriptions-item>

            </el-descriptions>
          </div>


          <span slot="footer" class="dialog-footer">
    <el-button @click="userInfoDialogVisible = false">关闭</el-button>
    <el-button type="primary" @click="userInfoDialogVisible = false">确 定</el-button>
  </span>
        </el-dialog>

        <!--          编辑项目信息弹窗-->
        <el-dialog
            title=项目信息
            :visible.sync="editProjectDialogVisible"
            width="50%"
        >
          <div style="display: flex;align-items: center;flex-direction: column ;width: 100%">


            <el-form label-position="top"
                     style="display: flex; justify-content: center;flex-direction: column;width: 100%"
                     :model="editProjectEntity">
              <!--                无法更改的内容：项目Id，项目组长，项目创建人，项目创建时间-->
              <div style="display: flex ;justify-content: center;align-items: center">
                <el-form-item label="项目Id" style="width: 100%;margin: 6px">
                  <el-input disabled='true' v-model="editProjectEntity.projectId"></el-input>
                </el-form-item>
                <el-form-item label="项目创建人" style="width: 100%;margin: 6px">
                  <el-input disabled='true' v-model="editProjectEntity.createUserName"></el-input>
                </el-form-item>

              </div>
              <div style="display: flex ;justify-content: center;align-items: center">
                <el-form-item label="项目组长" style="width: 100%;margin: 6px">
                  <el-input disabled='true' v-model="editProjectEntity.projectLeaderName"></el-input>
                </el-form-item>

                <el-form-item label="创建时间" style="width: 100%;margin: 6px">
                  <el-input disabled='true' v-model="editProjectEntity.createTime"></el-input>
                </el-form-item>
              </div>

              <!--                可以更改的内容：项目名称，项目完成时间-->
              <div style="display: flex ;justify-content: left;align-items: center">
                <el-form-item label="项目名称" style="width: 50%;margin: 6px">
                  <el-input v-model="editProjectEntity.projectName"></el-input>
                </el-form-item>
                <el-form-item label="项目状态" style="width: 50%;margin: 6px">
                  <el-select v-model="editProjectEntity.projectStatus" placeholder="请选择项目状态">
                    <el-option label="未开始" value=0></el-option>
                    <el-option label="进行中" value=1></el-option>
                    <el-option label="已完成" value=2></el-option>
                  </el-select>
                </el-form-item>
              </div>

            </el-form>
          </div>


          <span slot="footer" class="dialog-footer">
    <el-button @click="editProjectDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="editProjectInfo">修 改</el-button>
  </span>
        </el-dialog>


        <!--        新增项目弹窗-->
        <el-dialog
            title=新增项目
            :visible.sync="addProjectDialogVisible"
            width="50%"
        >
          <div style="display: flex;align-items: center;flex-direction: column ;width: 100%">

            <el-form label-position="top"
                     style="display: flex; justify-content: center;flex-direction: column;width: 100%"
                     :model="addProjectEntity">
              <!--                无法更改的内容：项目Id，项目组长，项目创建人，项目创建时间-->
              <div style="display: flex ;justify-content: left;align-items: center">
                <el-form-item label="项目创建人Id" style="width: 37%;margin: 6px">
                  <el-input disabled="true" v-model="addProjectEntity.createUserId"></el-input>
                </el-form-item>
              </div>

              <div style="display: flex ;justify-content: left;align-items: center">

                <el-form-item label="创建时间">
                  <el-date-picker type="date" placeholder="选择日期" v-model="addProjectEntity.createTime"
                                  style="width: 100%;"></el-date-picker>
                </el-form-item>
              </div>
              <!--                可以更改的内容：项目名称，项目完成时间-->
              <div style="display: flex ;justify-content: left;align-items: center">
                <el-form-item label="项目名称" style="width: 50%;margin: 6px">
                  <el-input v-model="addProjectEntity.projectName"></el-input>
                </el-form-item>

              </div>

              <div style="display: flex ;justify-content: left;align-items: center">

                <el-form-item label="完成时间">
                  <el-date-picker type="date" placeholder="选择日期" v-model="addProjectEntity.completionTime"
                                  style="width: 100%;"></el-date-picker>
                </el-form-item>
              </div>
            </el-form>
          </div>


          <span slot="footer" class="dialog-footer">
    <el-button @click="closeAddProjectDialog">取 消</el-button>
    <el-button type="success" @click="createProject">新增项目</el-button>
  </span>
        </el-dialog>
      </div>

    </div>
    <!--     分页组件 -->
    <div style="display: flex;align-items: center;justify-content: center;margin: 6px">
      <el-pagination
          class="pagination"
          background
          layout="prev, pager, next"
          :pageSize="pageSize"
          :total="total"
          @current-change="change"
      >
      </el-pagination>
    </div>

  </div>

</template>

<script>
export default {
  name: "ProjectManagement",
  data() {
    return {
//分页相关
      pageSize: 10, //设置默认值为12条一页
      total: 0,
      pageNum: 0,
      loginUserRole: JSON.parse(localStorage.getItem("loginUserRole")),
      tabPosition: 'all',//任务状态的表格显示
      loginUser: JSON.parse(localStorage.getItem("loginUser")), //当前登录用户
      projectTableData: [],//项目表的绑定数据
      searchValue: '',//条件查询数据绑定
      projectStatusSelectValue: 3, //项目状态条件查询数据绑定

      projectUsersList: [],//当前项目的员工集合
      projectMembersDialogVisible: false, //项目组员信息弹窗显示
      projectPersonnelAllocationValue: '',//项目人员分配选中
      userInfoDialogVisible: false,//用户信息弹窗显示
      userInfo: {},//用户信息弹窗显示
      editProjectDialogVisible: false, //项目编辑弹窗显示

      editProjectEntity: {//项目编辑实体绑定
        projectId: "",
        projectName: "",
        createUserId: 0,
        projectLeaderId: 0,
        createTime: [],
        projectStatus: 0,
        createUserName: "",
        projectLeaderName: "",
        projectStatusName: "",
        completionTime: []
      },
      assignDialogVisible: false, //指派项目组长弹窗显示
      projectLeaders: [], //可用来分配的项目组长
      assignProjectId: "", //需要指派的项目Id绑定
      assignProject: {}, //需要指派的项目实体

      addProjectEntity: {
        projectId: "",
        projectName: "",
        createUserId: 0,
        projectLeaderId: 0,
        createTime: "",
        projectStatus: 0,
        createUserName: "",
        projectLeaderName: "",
        projectStatusName: "",
        completionTime: ""
      },//新增项目的实体绑定

      addProjectDialogVisible: false, //新增项目弹窗显示绑定


    }
  },
  mounted() {
    //获取表格数据
    this.$request.get("/project/getProjectConditionalQueryByPage", {
      params: {
        selectValue: this.searchValue,
        projectStatusSelectValue: this.projectStatusSelectValue,
        currentPage: this.pageNum,
        pageSize: this.pageSize,
      }
    }).then(res => {
      if (res.successFlag) {
        this.projectTableData = res.data.pageData
        this.total = res.data.totalData
      } else {
        this.$message.error(res.errorMsg)
      }
    })
  },
  methods: {
//日期转换
    timeFormatConversion(projectTime) {
      let showDate = ''
      /*if (publishTime != null) {
        showDate = publishTime[0] + '年' + publishTime[1] + '月' + publishTime[2] + '日' + '-' + publishTime[3] + ':' + publishTime[4]
      } else {
        showDate = '暂无日期'
      }*/
      const [year, month, day, hours, minutes] = projectTime;

      if (projectTime == null) {
        showDate = "暂无日期"
        return showDate
      }
      // Format time as "YYYY年M月D日-HH：mm"
      const formattedTime = `${year}年${month}月${day}日-${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
      // Save the formatted time string to the data property
      showDate = formattedTime
      return showDate
    },
    //项目状态显示
    switchProjectStatus(projectStatus) {
      let reslut = {
        tagStyle: '',
        projectStatusName: ''
      }
      if (projectStatus === '未开始') {
        reslut.tagStyle = 'warning'
        reslut.projectStatusName = '未开始'
        return reslut
      } else if (projectStatus === '进行中') {
        reslut.tagStyle = ''
        reslut.projectStatusName = '进行中'
        return reslut
      } else if (projectStatus === '已完成') {
        reslut.tagStyle = 'success'
        reslut.projectStatusName = '已完成'
        return reslut
      }
      return reslut
    },
    //分页控件换页功能
    change(pageNum) {
      this.pageNum = pageNum;
      this.getProjectConditional();
      /*this.getMyNotesConditional();*/
    },

    //通过项目id或者项目名称来搜索项目数据
    selectProjectByIdOrName() {
      this.$request.get("/project/selectProjectByIdOrName", {
        params: {
          selectValue: this.searchValue
        }
      }).then(res => {
        if (res.successFlag) {
          this.projectTableData = res.data
        } else {
          this.$message.error("查询失败！")
        }
      })

    },

    //项目编辑弹窗显示
    toMyProjectEdit(projectEntity) {
      //将选择的编辑项目赋值给项目编辑实体
      this.editProjectEntity = projectEntity
      //项目信息编辑弹窗显示
      this.editProjectDialogVisible = true
    },

    //修改项目信息
    editProjectInfo() {
      this.$request.put("/project/editProjectInfo", this.editProjectEntity).then(res => {
        if (res.successFlag) {
          this.$message.success("修改项目成功！")
          this.editProjectDialogVisible = false
        } else {
          this.$message.error(res.errorMsg)
          this.editProjectDialogVisible = false
        }
      })
    },

    //新增项目
    createProject() {
      this.$request.post("/project/addProject" + "?loginUser=" + this.loginUser.uid, this.addProjectEntity).then(res => {
        if (res.successFlag) {
          this.$message.success("新增项目成功！")
          //关闭新增弹窗
          this.addProjectDialogVisible=false
          //新增成功后刷新页面
          window.location.reload();
        } else {
          this.$message.error(res.errorMsg)
        }
      })

    },


    //删除项目
    delProject(projectId) {
      this.$request.delete("/project/delProject" + "?projectId=" + projectId + "&userId=" + this.loginUser.uid).then(res => {
        if (res.successFlag) {
          this.$message.success("删除项目成功！")
          this.getProjectConditional()
        } else {
          this.$message.error(res.errorMsg)
        }
      })

    },

    async changeTab(queryCriteria) {
      //选择了任务状态作为条件，把分页参数重置
      this.pageNum = 1
      this.tabPosition = queryCriteria
      if (queryCriteria === "undo") {
        this.projectStatusSelectValue = 0
      } else if (queryCriteria === "doing") {
        this.projectStatusSelectValue = 1
      } else if (queryCriteria === "done") {
        this.projectStatusSelectValue = 2
      } else if (queryCriteria === "all") {
        this.projectStatusSelectValue = 3
      }
      /*await this.getMyNotesConditional()*/
      await this.getProjectConditional();
    },

    async getProjectConditional() {
      await this.$request.get("/project/getProjectConditionalQueryByPage", {
        params: {
          selectValue: this.searchValue,
          projectStatusSelectValue: this.projectStatusSelectValue,
          currentPage: this.pageNum,
          pageSize: this.pageSize,
        }
      }).then(res => {
        if (res.successFlag) {
          this.projectTableData = res.data.pageData
          this.total = res.data.totalData
        } else {
          this.$message.error(res.errorMsg)
        }
      })
    },

    //显示指派弹窗
    showAssign(currentProjectLeaderId, currentProject) {
      //显示指派弹窗
      this.assignDialogVisible = true

      //确定当前需要指派的项目
      this.assignProject = currentProject

      //查询出除当前项目项目组长以为的所有项目组长数据
      this.$request.get("/user/getAllProjectLeader", {
        params: {
          currentProjectLeaderId: currentProjectLeaderId
        }
      }).then(res => {
        if (res.successFlag) {
          this.projectLeaders = res.data
        } else {
          this.$message.error("查询项目组员信息失败！")
        }
      })

    },


    //指派当前用户为当前项目的项目组长
    assign(projectLeaderId) {

      this.$request.post("/project/projectAssignment" + "?userId=" + this.loginUser.uid + "&projectLeaderId=" + projectLeaderId, this.assignProject)
          .then(res => {
            if (res.successFlag) {
              this.assignDialogVisible = false
              window.location.reload();
              this.$message.success("指派成功！")

            } else {
              this.assignDialogVisible = false
              this.$message.error(res.errorMsg)
            }
          })
    },

    //显示项目组员
    showProjectUsers(projectId) {
      //1.打开项目组员的弹窗
      this.projectMembersDialogVisible = true
      this.projectPersonnelAllocationValue = projectId
      //获取项目组员
      this.$request.get("/user/getProjectEmployees", {
        params: {
          loginUser: localStorage.getItem("loginUser"),
          projectId: projectId
        }
      }).then(res => {
        if (res.successFlag) {
          this.projectUsersList = res.data
        } else {
          this.$message.error("查询项目组员信息失败！")
        }
      })
    },

    //显示员工详情信息
    showUserInfo(userId) {
      //弹窗显示
      this.userInfoDialogVisible = true
      //根据userId找到用户信息绑定到userInfo中
      this.projectUsersList.forEach(user => {
        // 找到 uid 为 7 的对象
        if (user.uid === userId) {
          // 将找到的对象赋值给 userInfo
          this.userInfo = user
        }
      });
    },


    //从项目中移除成员
    async removeFormProject(userId) {
      await this.$request.delete("/project/removeFormProject" + "?projectId=" + this.projectPersonnelAllocationValue
          + "&userId=" + userId).then(res => {
        if (res.successFlag) {
          //添加成功，刷新 项目组员信息、员工列表、 新增项目成员
          this.$message.success("项目组员删除成功！")
          this.getAllShowDataForDistribution();
          this.projectAddUserList = []
          this.delUserFormProjectVisible = false
        } else {
          this.$message.error("项目组员删除失败！")
          this.delUserFormProjectVisible = false
        }
      })
    },

    //创建项目弹窗显示
    openAddProjectDialog(){
      //1.将addProjectEntity中的字段进行填充
      let uid = this.loginUser.uid;
      this.addProjectEntity.createUserId=uid
      //2.弹窗显示
      this.addProjectDialogVisible=true
    },

    //创建项目弹窗关闭
    closeAddProjectDialog(){
      //1.将addProjectEntity恢复成原始状态
      let originEntity= {
        projectId: "",
        projectName: "",
        createUserId: 0,
        projectLeaderId: 0,
        createTime: [],
        projectStatus: 0,
        createUserName: "",
        projectLeaderName: "",
        projectStatusName: "",
        completionTime: []
      }
      this.addProjectEntity=originEntity

      //2.关闭弹窗
      this.addProjectDialogVisible=false
    }
  }
}
</script>

<style scoped>
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}

.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
</style>